const express = require('express')
const app = express()

const path = require("path")
const dirRouter = path.join(__dirname, "router")
const router = require(dirRouter)

app.get('/api/jsonp', (req, res) => {
    const funcName = req.query.callback
    const data = {
        name: 'zx',
        age: 22
    }
    const scriptStr = `${funcName}(${JSON.stringify(data)})`
    res.send(scriptStr)
})

app.use(router)

app.listen(8080, () => {
    console.log("已经成功启动服务器")
})